import { Component, OnInit } from '@angular/core'

import { File } from './../../models/file'

import { FileService } from './../../services/file.service'

const files: File[] = [
  {
    id: 1,
    name: '双均线策略',
    content: 'ma30 和 ma60 金叉买入 死叉卖出'
  },

  {
    id: 2,
    name: '招行伊利轮动策略',
    content: '招商银行和伊利股份轮动操作'
  },

  {
    id: 3,
    name: '这是一个简单的策略-1',
    content: '默认新建策略'
  },

  {
    id: 4,
    name: '这是一个简单的策略-2',
    content: '默认新建策略'
  },

  {
    id: 5,
    name: '这是一个简单的策略-3',
    content: '默认新建策略'
  },

  {
    id: 6,
    name: '这是一个简单的策略-4',
    content: '默认新建策略'
  },

  {
    id: 7,
    name: '这是一个简单的策略-5',
    content: '默认新建策略'
  },

  {
    id: 8,
    name: '这是一个简单的策略-6',
    content: '默认新建策略'
  }
]

@Component({
  selector: 'jq-files',
  templateUrl: './files.component.html'
})
export class FilesComponent implements OnInit {

  ngOnInit(): void {
    this.onGetFiles();
  }

  constructor(
    private fileService: FileService
  ) {}

  files: File[];

  onGetFiles(): void {
    // this.fileService.getFiles()
    this.fileService.getFilesSlowly()
      .then(files => this.files = files)
  }
}
